//
//  GeRenXinXiViewController.m
//  ShouKuang
//
//  Created by CodeYY on 2019/6/3.
//  Copyright © 2019 CodeYY. All rights reserved.
//

#import "GeRenXinXiViewController.h"
@interface GeRenXinXiViewController()
@property(nonatomic, weak)UIView *headView;
@property(nonatomic, weak)UIView *contentView;
@property(nonatomic, weak)UIButton *actionBtn;
@property(nonatomic, strong)NSArray *dataAry;
@end

@implementation GeRenXinXiViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNavBar];
    
    self.dataAry = @[@"公司",@"部门",@"职位",@"手机号",@"邮箱",@"角色"];
    [self initCustomUI];
    
    
    
    // Do any additional setup after loading the view.
}

-(void)initNavBar
{
    WEAKSELF
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setImage:[UIImage imageNamed:@"nav_back_red"] forState:UIControlStateNormal];
    [leftBtn setTitle:@"返回" forState:UIControlStateNormal];
    [leftBtn setTitleColor:YYRGB(129, 129, 129) forState:UIControlStateNormal];
    [leftBtn jk_setImagePosition:LXMImagePositionLeft spacing:5];
    [[leftBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    
    self.title = @"个人信息";
}

-(void)initCustomUI
{
    
    // t头像信息
    UIView *headView = [UIView new];
    [self.view addSubview:headView];
    _headView = headView;
    headView.backgroundColor = [UIColor whiteColor];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(70);
        make.height.mas_equalTo(80);
    }];
    
    UIImageView *img = [UIImageView new];
    [headView addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.centerY.offset(0);
        make.size.mas_equalTo(CGSizeMake(25, 25));
    }];
    img.layer.cornerRadius = 25/2;
    img.layer.masksToBounds = YES;
    
    UILabel *titleLab = [UILabel new];
    [headView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(img.mas_right).offset(10);
        make.centerY.offset(0);
    }];
    titleLab.textColor = [UIColor lightGrayColor];
    
    // 赋值
    img.backgroundColor = [UIColor greenColor];
    titleLab.text = @"KVV";
    
    
    // 职位信息
    UIView *contentView = [UIView  new];
    contentView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:contentView];
    _contentView = contentView;
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(headView.mas_bottom).offset(20);
    }];
    
        for (int i =0 ; i < self.dataAry.count; i++) {
            
            UIView *topView = self.contentView.subviews.lastObject;
            UIView *cellView = [self cellContentView];
            [self.contentView addSubview:cellView];
            [cellView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.left.offset(0);
                make.height.mas_equalTo(50);
                if (i == 0) {
                    make.top.offset(0);
                }else if (i == self.dataAry.count -1){
                    make.top.equalTo(topView.mas_bottom);
                    make.bottom.offset(0);
                }else{
                    make.top.equalTo(topView.mas_bottom);
                }
            }];
            
            UILabel *titleLab = [cellView viewWithTag:1000];
            UILabel *contentLab = [cellView viewWithTag:1001];
            
            if ([self.dataAry[i] isEqualToString:@"公司"]) {
                titleLab.text = @"公司";
                contentLab.text= @"深圳中心开发中心";
            }else if ([self.dataAry[i] isEqualToString:@"部门"]){
                titleLab.text = @"部门";
                contentLab.text= @"财务部";
            }else if ([self.dataAry[i] isEqualToString:@"职位"]){
                titleLab.text = @"职位";
                contentLab.text= @"可自己完善";
            }else if ([self.dataAry[i] isEqualToString:@"手机号"]){
                titleLab.text = @"手机号";
                contentLab.text= @"313213123";
            }else if ([self.dataAry[i] isEqualToString:@"邮箱"]){
                titleLab.text = @"邮箱";
                contentLab.text= @"可自己完善";
            }else if ([self.dataAry[i] isEqualToString:@"角色"]){
                titleLab.text = @"角色";
                contentLab.text= @"超级管理员";
            }
            
        }
    
    
 // button
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    _actionBtn = btn;
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.height.mas_equalTo(50);
        make.top.equalTo(contentView.mas_bottom).offset(50);
    }];
    btn.backgroundColor = [UIColor whiteColor];
    [btn setTitle:@"删除人员" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [[btn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(id x) {
        
    }];
    
}

-(UIView *)cellContentView
{
    UIView *cellView = [UIView new];
    cellView.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLab = [UILabel new];
    [cellView addSubview:titleLab];
    titleLab.tag = 1000;
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.centerY.offset(0);
        make.width.mas_equalTo(50);
        
    }];
    titleLab.textColor = [UIColor lightGrayColor];
    titleLab.font = [UIFont systemFontOfSize:14];
    
    UILabel *contentLab = [UILabel new];
    [cellView addSubview:contentLab];
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLab.mas_right).offset(20);
        make.right.offset(0);
        make.centerY.offset(0);
    }];
    contentLab.tag = 1001;
    contentLab.textColor = [UIColor darkTextColor];
    contentLab.font = [UIFont systemFontOfSize:14];
    
    UIView *line = [UIView new];
    [cellView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.mas_equalTo(0.5);
    }];
    line.backgroundColor = [UIColor lightGrayColor];
    
    return cellView;
}

@end
